package com.laoluo.erp.struts.action;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Component;

@Component
@SuppressWarnings("serial")
public class LessonAction extends BaseAction {

	//lesson04 ajax.js
	public void AjaxTest()
	{
	
		Person p1 = new Person();
		p1.setName("laoluo");
		p1.setAge(32);
		p1.setEmail("laoluo@263.com");

		writeJson(p1);
	}
	
	public void deleteUsers()
	{
		String ids = getRequest().getParameter("ids");
		System.out.println(ids);
		resultSuccess("删除成功");
	}
	
	public void getUserList2() throws ParseException
	{
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

		List<Person> list = new ArrayList<Person>();	
		Person p1 = new Person();
		p1.setId(1);
		p1.setName("laoluo");
		p1.setAge(32);
		p1.setEmail("laoluo@263.com");
		p1.setMoney(1238.34);
		p1.setBirthday(sdf.parse("1980-02-14"));
		p1.setSex("男");
		p1.setIsIT(true);
		list.add(p1);
		
		Person p2 = new Person();
		p2.setId(2);
		p2.setName("Bibi");
		p2.setAge(32);
		p2.setEmail("bibi@263.com");
		p2.setMoney(10.00);
		p2.setBirthday(sdf.parse("1979-06-03"));
		p2.setSex("女");
		p2.setIsIT(true);
		list.add(p2);
		
		Person p3 = new Person();
		p3.setId(3);
		p3.setName("XinLin");
		p3.setAge(32);
		p3.setEmail("Xinlin@263.com");
		p3.setMoney(23.03);
		p3.setBirthday(sdf.parse("2007-11-14"));
		p3.setSex("女");
		p3.setIsIT(false);
		list.add(p3);
		
		resultSuccess("查询成功",list,list.size());
	}
	
	public void getUserList()
	{
		List<Person> list = new ArrayList<Person>();	
		Person p1 = new Person();
		p1.setName("laoluo");
		p1.setAge(32);
		p1.setEmail("laoluo@263.com");
		list.add(p1);
		
		Person p2 = new Person();
		p2.setName("Bibi");
		p2.setAge(32);
		p2.setEmail("bibi@263.com");
		list.add(p2);
		
		Person p3 = new Person();
		p3.setName("XinLin");
		p3.setAge(32);
		p3.setEmail("Xinlin@263.com");
		list.add(p3);
		
		resultSuccess("查询成功",list,list.size());
	}
	private static int i =0;
	public void getTime(){
		i=i+1;
		writeString(i+"");
	}
	
}
class Person{
	private String name;
	private int age;
	private String email;
	private int id;
	private Date birthday;
	private Double money;
	private String description;
	private String sex;
	private Boolean isIT;
	
	public String getSex() {
		return sex;
	}
	public void setSex(String sex) {
		this.sex = sex;
	}
	public Boolean getIsIT() {
		return isIT;
	}
	public void setIsIT(Boolean isIT) {
		this.isIT = isIT;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public Date getBirthday() {
		return birthday;
	}
	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}
	public Double getMoney() {
		return money;
	}
	public void setMoney(Double money) {
		this.money = money;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}

}